package com.wang.honi.Utils;

import androidx.appcompat.app.AppCompatActivity;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.os.Bundle;
import android.widget.Toast;

import com.wang.honi.Callback.BleCallback;
import com.wang.honi.R;

public class DataExchangeActivity extends AppCompatActivity {

    private static final String TAG = DataExchangeActivity.class.getSimpleName();
    private BluetoothGatt bluetoothGatt;//gatt
    private boolean isConnected = false;//设备是否连接
    private BleCallback bleCallback;//gatt回调

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_data_exchange);

        //初始化
        bleCallback = new BleCallback();
        //获取上个页面传递过来的设备
        BluetoothDevice device = getIntent().getParcelableExtra("device");
        bluetoothGatt = device.connectGatt(this, false, bleCallback);
    }

    /**
     * 断开设备连接
     */
    private void disConnectDevice() {
        if (isConnected && bluetoothGatt != null){
            bluetoothGatt.disconnect();
        }
    }
    
    private void showMsg(String msg){
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }
}


